﻿<?xml version="1.0" encoding="UTF-8"?>
<!--=============================================================
    File: LeftNav.xslt                                                   
    Created by: sitecore\admin                                       
    Created: 7/26/2010 10:56:13 AM                                               
    Copyright notice at bottom of file
==============================================================-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sc="http://www.sitecore.net/sc" xmlns:dot="http://www.sitecore.net/dot" exclude-result-prefixes="dot sc">
	<!-- output directives -->
	<xsl:output method="html" indent="no" encoding="UTF-8" />
	<!-- parameters -->
	<xsl:param name="lang" select="'en'" />
	<xsl:param name="id" select="''" />
	<xsl:param name="sc_item" />
	<xsl:param name="sc_currentitem" />
	<!-- variables -->
	<!-- Uncomment one of the following lines if you need a "home" variable in you code -->
	<xsl:variable name="home" select="sc:item('/sitecore/content/EFI/MIS_ERP/',.)" />
	<!--<xsl:variable name="home" select="/*/item[@key='content']/item[@key='home']" />-->
	<!--<xsl:variable name="home" select="$sc_currentitem/ancestor-or-self::item[@template='site root']" />-->
	<!-- entry point -->
	<xsl:template match="*">
		<xsl:apply-templates select="$sc_item" mode="main" />
	</xsl:template>
	<!--==============================================================-->
	<!-- main                                                         -->
	<!--==============================================================-->
	<xsl:template match="*" mode="main">
		<ol id="mainNavigation">
			<xsl:variable name="classHome">
				<xsl:if test="$sc_currentitem = $home">selected </xsl:if>
				<xsl:if test="$sc_currentitem/self::item/@name = 'Home'">selected </xsl:if>
			</xsl:variable>
			<li class="{$classHome}">
				<xsl:variable name="homeUrl">
					<sc:text field="HomeUrl" select="$home"/>
				</xsl:variable>
				<a href="{$homeUrl}"><span><span><sc:text field="NavTitle" select="$home"/></span></span></a>
			</li>
			<xsl:for-each select="$home/item">
				<xsl:if test="sc:fld('Dont Show In Nav',.) != '1' and ./@template != 'folder'">
					<!-- First level -->
						<xsl:variable name="class1">
							<xsl:if test="./item">hasChildren </xsl:if>
							<xsl:if test="$sc_currentitem/self::item/@id = @id">selected </xsl:if>
							<xsl:if test="$sc_currentitem/ancestor::item/@id = @id">selected </xsl:if>
						</xsl:variable>
						<li class="{$class1}">
						<sc:link><span><span><sc:text field="NavTitle" /></span></span></sc:link>
						<xsl:if test="./item">
							<ol>
								<xsl:for-each select="./item">
									<!-- Second Level -->
									<xsl:if test="sc:fld('Dont Show In Nav',.)!=1 ">
										<xsl:variable name="class2">
											<xsl:if test="./item">hasChildren </xsl:if>
											<xsl:if test="$sc_currentitem/self::item/@id = @id">open selected </xsl:if>
											<xsl:if test="$sc_currentitem/ancestor::item/@id = @id">open </xsl:if>
										</xsl:variable>
										<li class="{$class2}">
											<sc:link><span><span>&gt; <sc:text field="NavTitle" /></span></span></sc:link>
											<xsl:if test="./item">
												<ol>
													<xsl:for-each select="./item">
														<!-- Third Level -->
														<xsl:if test="sc:fld('Dont Show In Nav',.) != 1">
															<xsl:variable name="class3">
																<xsl:if test="./item">hasChildren </xsl:if>
																<xsl:if test="$sc_currentitem/self::item/@id = @id">open selected </xsl:if>
																<xsl:if test="$sc_currentitem/ancestor::item/@id = @id">open </xsl:if>
															</xsl:variable>
															<li class="{$class3}">
																<sc:link><span><span>&gt; <sc:text field="NavTitle" /></span></span></sc:link>																
																<xsl:if test="./item">
																	<ol>
																		<xsl:for-each select="./item">
																			<!-- Fourth Level -->
																			<xsl:if test="sc:fld('Dont Show In Nav',.)!=1">
																					<xsl:variable name="class4">
																						<xsl:if test="$sc_currentitem/self::item/@id = @id">open selected </xsl:if>
																						<xsl:if test="$sc_currentitem/ancestor::item/@id = @id">open </xsl:if>
																						<xsl:if test="$sc_currentitem/parent::item/@id = @id">hasChildren selected</xsl:if>
																					</xsl:variable>
																				<li class="{$class4}">
																					<sc:link><span><span>&gt; <sc:text field="NavTitle" /></span></span></sc:link>
																				</li>
																			</xsl:if>
																		</xsl:for-each>
																	</ol>
																</xsl:if>
															</li>
														</xsl:if>
													</xsl:for-each>
												</ol>
											</xsl:if>
										</li>
									</xsl:if>
								</xsl:for-each>
							</ol>
						</xsl:if>
					</li>
				</xsl:if>
			</xsl:for-each>
		</ol>
    <sc:link field="LC Image link">
      <sc:image field="LC Image" class="main" />
    </sc:link>    
  </xsl:template>
</xsl:stylesheet>